﻿$.validator.addMethod("SumCommisRate", function (value, element, params) {
    debugger;
    var sumr = params.MaxCommisRate;
    var r = params.CommisRate;
    var r1 = params.CommisRateOne;
    var r2 = params.CommisRateTwo;
    var r3 = params.CommisRateThree;
    var numr = Number($('#' + r).val());
    var numr1 = Number($('#' + r1).val());
    var numr2 = Number($('#' + r2).val());
    var numr3 = Number($('#' + r3).val());
    var age = currentDate.getFullYear() - birthDate.getFullYear();
    if ((numr + numr1 + numr2 + numr3) < sumr) {
        return true;
    } else {
        return false;
    }
});

$.validator.unobtrusive.adapters.add("SumCommisRate", function (options) {
    debugger;
    options.rules["SumCommisRate"] = {
        MaxCommisRate: options.params.MaxCommisRate,
        CommisRateOne: options.params.CommisRateOne,
        CommisRateTwo: options.params.CommisRateTwo,
        CommisRateThree: options.params.CommisRateThree,
        CommisRate: options.params.CommisRate
    };
    options.messages["SumCommisRate"] = options.message;
 });